Skip to content

[CAMEL-21032] Generate k8s service for health endpoint#14971

Merged
christophd merged 1 commit intoapache:mainfrom
tdiesler:CAMEL-21032
Aug 2, 2024
Merged

[CAMEL-21032] Generate k8s service for health endpoint#14971
christophd merged 1 commit intoapache:mainfrom
tdiesler:CAMEL-21032

Conversation

@tdiesler
Copy link
Contributor

Copy link
Contributor

@christophd christophd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we enhance the TraitHelper.exposesHttpService() logic to understand that there is a health endpoint exposed? Something needs to listen on the port to return the health status. I still do not understand what represents this health endpoint

Assertions.assertEquals("NodePort", service.getSpec().getType());
Assertions.assertEquals(1, ports.size());
Assertions.assertEquals("http", ports.get(0).getName());
Assertions.assertEquals(8080, ports.get(0).getPort());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Kubernetes service should be exposed on port 80 by default so other components in the cluster can call the service with its pure domain name URL (e.g. http://my-service.default/ instead of http://my-service.default:8080/

// We may (later) decide that the health endpoint can be disabled.
// if (!TraitHelper.exposesHttpService(context)) {
// TraitHelper.configureHttpService(traitsSpec);
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to implement this TraitHelper.configureHttpService(traitsSpec);?

return traitConfig.getService().getEnabled();
}

if (traitConfig.getContainer().getPort() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need similar for the Knative trait as it also checks on TraitHelper.exposesHttpService()

@tdiesler
Copy link
Contributor Author

You can now do this ...

git clone https://github.com/tdiesler/camel-cloud-examples
cd camel-cloud-examples/spring-boot/http-roll-dice

make package k8s-apply

kubectl get svc
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        6d2h
roll-dice    NodePort    10.110.21.17   <none>        80:32615/TCP   80s

curl localhost:32615/roll-dice
roll: 6

curl localhost:32615/actuator/health
{"status":"UP","groups":["liveness","readiness"]}

@christophd christophd merged commit 62e3d91 into apache:main Aug 2, 2024
@tdiesler tdiesler deleted the CAMEL-21032 branch August 5, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants